<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
<script src="https://cdn.staticfile.org/vue/2.4.2/vue.min.js"></script>
<script
	src="https://cdn.staticfile.org/vue-router/2.7.0/vue-router.min.js"></script>
<script src="https://cdn.staticfile.org/axios/0.18.0/axios.min.js"></script>
<style type="text/css">
.site-form {
	margin-top: 150px;
}

#button {
	margin-left: 90px;
}
</style>
</head>
<body>

	<div class="row" id="app" style="margin-top: 100px;">
		<div class="col-sm-3"></div>
		<div class="col-sm-6" id="app">
			<div class="form-group">
				
				
				<label>请输入问题</label> <input type="text"
					class="form-control" v-model="question" style="height: 40px; width: 400px;">
				<p></p>
				<label>请输入答案</label> <input type="text"
					class="form-control" v-model="answer" style="height: 40px; width: 400px;">
				<p></p>
				<label>请输入密码 </label> <input type="password"
					class="form-control" v-model="password" style="height: 40px; width: 400px;">
			</div>
			<p><button @click="submit()" class="btn btn-primary" id="button" style="margin-left: 25%;">提交问题</button></p>
			<label id="ties" style="color: red;"></label>


		</div>
		<div class="col-sm-3"></div>
	</div>

	<script type="text/javascript">
	new Vue({
		el:"#app",
		data: {
			   question:'',
			   answer:'',
			   password:''
			 },
			//页面加载完后触发
			mounted(){
				
			},
			methods:{
			submit:function(){
				var answer = this.answer;
				var question = this.question;;
				var password=this.password;
				if(answer == "" || answer == null || answer == undefined){
					document.getElementById("ties").innerHTML="请输入答案";
					setTimeout(function (){
						 
						window.location.reload();
					},3000);
					return;
				}
				if(question == "" || question == null || question == undefined){
					document.getElementById("ties").innerHTML="请输入问题";
					setTimeout(function (){
						 
						window.location.reload();
					},3000);
					return;
				}
				if(password == "" || password == null || password == undefined){
					document.getElementById("ties").innerHTML="请输入密码";
					setTimeout(function (){
						 
						window.location.reload();
					},3000);
					return;
				}
					alert(1);
					axios.get("user/addsecutity?question="+question+"&password="+password+"&answer="+answer).then(res => {
						console.info(res.data);
						if(res.data==1){
							document.getElementById("ties").innerHTML="设置密保问题成功";
							setTimeout(function (){
								 
								window.location.reload();
							},3000);
						}else if(res.data==0){
							document.getElementById("ties").innerHTML="已经有三个密保问题了,若要修改密保问题,请前往修改密保模块";
							setTimeout(function (){
								 
								window.location.reload();
							}, 3000);
						}else{
							document.getElementById("ties").innerHTML="密码错误，请重新出入";
							setTimeout(function (){
								 
								window.location.reload();
							}, 3000);
						}
						
						
					})
			}
		
			
		}
	});
	</script>
</body>
</html>
